package in.iqing.control.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import java.util.List;

import butterknife.Bind;
import butterknife.ButterKnife;
import in.iqing.app.R;

/**
 * Created by neavo on 2014/6/24.
 */

public class AboutItemAdapter extends BaseAdapter {

	private Context ctx;
	private List<String> texts;

	public AboutItemAdapter(Context ctx, List<String> texts) {
		this.ctx = ctx;
		this.texts = texts;
	}

	@Override
	public int getCount() {
		return texts.size();
	}

	@Override
	public String getItem(int position) {
		return texts.get(position);
	}

	@Override
	public long getItemId(int position) {
		return position;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		if (convertView == null) {
			convertView = LayoutInflater
					.from(ctx)
					.inflate(R.layout.item_about, parent, false);
			convertView.setTag(new ViewHolder(convertView));
		}

		String text = getItem(position);
		ViewHolder holder = (ViewHolder) convertView.getTag();
		holder.aboutText.setText(text);

		return convertView;
	}

	public static class ViewHolder {

		@Bind(R.id.about_text)
		public TextView aboutText;

		public ViewHolder(View v) {
			ButterKnife.bind(this, v);
		}
	}
}
